<?php

/**
 * This is the model class for table "emergency_light".
 *
 * The followings are the available columns in table 'emergency_light':
 * @property integer $id
 * @property integer $automatic_emergency_light_provided
 * @property string $source_of_power
 * @property string $other
 * @property integer $no_of_unit_per_floor
 * @property string $located_at_stairway_landing
 * @property integer $operational
 * @property integer $exit_path_properly_illuminated
 * @property integer $tested_monthly
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class EmergencyLight extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return EmergencyLight the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

const a = "AC/DC";
const b ="Others";
public function getSource_of_power(){
return array(
self::a=>"AC/DC",
self::b=>"Others"
);


}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'emergency_light';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('automatic_emergency_light_provided, no_of_unit_per_floor, operational, exit_path_properly_illuminated, tested_monthly, inspection_id', 'numerical', 'integerOnly'=>true),
			array('source_of_power', 'length', 'max'=>6),
			array('other, located_at_stairway_landing', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, automatic_emergency_light_provided, source_of_power, other, no_of_unit_per_floor, located_at_stairway_landing, operational, exit_path_properly_illuminated, tested_monthly, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'automatic_emergency_light_provided' => 'Automatic Emergency Light Provided',
			'source_of_power' => 'Source Of Power',
			'other' => 'Other',
			'no_of_unit_per_floor' => 'No Of Unit Per Floor',
			'located_at_stairway_landing' => 'Located At Stairway Landing',
			'operational' => 'Operational',
			'exit_path_properly_illuminated' => 'Exit Path Properly Illuminated',
			'tested_monthly' => 'Tested Monthly',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('automatic_emergency_light_provided',$this->automatic_emergency_light_provided);
		$criteria->compare('source_of_power',$this->source_of_power,true);
		$criteria->compare('other',$this->other,true);
		$criteria->compare('no_of_unit_per_floor',$this->no_of_unit_per_floor);
		$criteria->compare('located_at_stairway_landing',$this->located_at_stairway_landing,true);
		$criteria->compare('operational',$this->operational);
		$criteria->compare('exit_path_properly_illuminated',$this->exit_path_properly_illuminated);
		$criteria->compare('tested_monthly',$this->tested_monthly);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}